package com.qi.spzx.manager.mapper;

import com.qi.spzx.model.entity.system.SysMenu;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Description TODO
 * @Author dingchunlin
 * @Date 2024/2/22 15:37
 * @Version 1.0.0
 */
@Mapper
public interface SysMenuMapper {


    @Select("select * from sys_menu where is_deleted = 1 order by sort_value")
    List<SysMenu> selectAll();

    void save(SysMenu sysMenu);

    void updateById(SysMenu sysMenu);

    @Select("select count(1) from sys_menu where is_deleted = 1 and parent_id = #{id}")
    Integer countByParentId(Long id);

    @Update("update sys_menu set update_time = now() ,is_deleted = 0 where id = #{id}")
    void deleteById(Long id);

    List<SysMenu> selectListByUserId(Long userId);

    @Select("select * from sys_menu where id = #{id}")
    SysMenu selectById(Long parentId);
}
